home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / ZoomBlur.ieb < prev   
Encoding:
Text File  |  1997-02-02  |  3.4 KB  |  141 lines

  1. /*
  2. ** $VER: ZoomBlur.ieb 1.11, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 2/2 1997 Stockholm/Sweden
  6. **
  7. ** Blur image with blur, max or min, using zooming technique.
  8. ** Based on the ZoomBlur.rexx script by Simon Edwards.
  9. */
  10.  
  11. options results
  12. signal on error
  13.  
  14. parse arg input command
  15. input = upper(strip(input))
  16. address 'IMAGEENGINEER'
  17.  
  18. select  /* Required batch script commands */
  19.   when input = 'INFO' then    return get_info()
  20.   when input = 'CONFIG' then  return get_config(command)
  21.   when input = 'PROCESS' then return process_image(command)
  22.   otherwise do
  23.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  24.     return '<ERROR>'
  25.   end
  26. end
  27.  
  28. exit 0
  29.  
  30. /* Required "Get_info" procedure  ------------------------------------ */
  31. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  32.  
  33. get_info:
  34.   back = 'OK'
  35. return back
  36.  
  37. /* Required "Get_config" procedure  ---------------------------------- */
  38.  
  39. get_config:
  40.   parse arg '"'command'"'
  41.  
  42.   Level=5
  43.  
  44.   if command ~= '' then parse var command '#'Method Level .
  45.  
  46.   'IE_TO_FRONT'
  47.  
  48.   form = 'FORM "Zoom Blur" " OK | Cancel "',
  49.   ' INTEGER,"Zoom level",0,50,'Level',SLIDER'
  50.  
  51.   if command = '' then do
  52.     form = form||' CYCLE,"Method:","Mix, (blur)|Max, (brighten) |Min, (darken)",0'
  53.     form
  54.     parse var result ok Level Method .
  55.     if ok = 0 then return '<ERROR>'
  56.   end
  57.   else do
  58.     form
  59.     parse var result ok Level .
  60.     if ok = 0 then return '<ERROR>'
  61.  
  62.     Method = 'none'
  63.   end
  64.  
  65.   back = '#'Method Level
  66. return back
  67.  
  68. /* Required "Process_image" procedure  ------------------------------- */
  69.  
  70. process_image:
  71.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  72.   parse var options '#'Method Level .
  73.  
  74.   'OPEN' '"'src_image'"' '24'
  75.   if (RC ~= 0) then do
  76.     'IE_TO_FRONT'
  77.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  78.     return '<ERROR>'
  79.   end
  80.   else LoadImage = result
  81.  
  82.   if Method = 0 then Method = 'MIX 50'
  83.   if Method = 1 then Method = 'MAX'
  84.   if Method = 2 then Method = 'MIN'
  85.  
  86.   Step = 2
  87.  
  88.   'PROJECT_INFO' LoadImage 'WIDTH'    /* Get width of image */
  89.   IW = RESULT
  90.   'PROJECT_INFO' LoadImage 'HEIGHT'    /* Get height of image */
  91.   IH = RESULT
  92.  
  93.   if Level ~= 0 then do
  94.     do w = 1 to Level
  95.       'SCALE' LoadImage IW+Step*w IH+Step*w 'BEST'
  96.       ScaleImage = result
  97.  
  98.       'MARK' ScaleImage 'PRIMARY'
  99.       'MARK' LoadImage 'SECONDARY'
  100.       'COMPOSITE' trunc(w*Step/(-2)) trunc(w*Step/(-2)) Method
  101.       CompImage = result
  102.       'CLOSE' ScaleImage
  103.       'CLOSE' LoadImage
  104.       LoadImage = CompImage
  105.     end
  106.   end
  107.  
  108.   OutputImage = LoadImage
  109.  
  110.   'SAVE_DATA' OutputImage '"'dst_image'"' '"ILBM CmpByteRun1"'
  111.   if (RC ~= 0) then do
  112.     'IE_TO_FRONT'
  113.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  114.     return '<ERROR>'
  115.   end
  116.   'CLOSE' OutputImage
  117.  
  118.   back = 'OK'
  119. return back
  120.  
  121. /* Internal procedures  ---------------------------------------------- */
  122.  
  123. /*******************************************************************/
  124. /* This is where control goes when an error code is returned by IE */
  125. /* It puts up a message saying what happened and on which line     */
  126. /*******************************************************************/
  127.  
  128. error:
  129. if RC=5 then do
  130.     IE_TO_FRONT
  131.     LAST_ERROR
  132.     'REQUEST "'||RESULT||'"'
  133. end
  134. else do
  135.     IE_TO_FRONT
  136.     LAST_ERROR
  137.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  138. end
  139.  
  140. return '<ERROR>'
  141.